import Vue from 'vue'
import axios from 'axios'

const OSS = require('ali-oss');

axios.get(`/file/oss/token`)
    .then((data) => {
        let oss = data.data;

        const client = new OSS({
            region: oss.region,
            accessKeyId: oss.accessKeyId,
            accessKeySecret: oss.accessKeySecret,
            stsToken: oss.stsToken,
            refreshSTSTokenInterval: 3600,
            bucket: oss.bucket,
        });

        Vue.prototype.ossClient = client;
    })